#ifdef HIDLOADER_EXPORTS
#define HIDLOADER_API __declspec(dllexport)
#else
#define HIDLOADER_API __declspec(dllimport)
#endif

#define		WM_LOADER		WM_USER + 101
#define		WML_DISABLE_ITEMS		1			/// Disable items
#define		WML_ENABLE_ITEMS		2			/// Enable items
#define		WML_UPDATE_STATUS		3			/// Update status
#define		WML_DUMP_DONE			4			/// Dump data finish

struct IProgressRender{
    virtual void SetRange(int start, int end) = 0;
    virtual void SetPos(int pos) = 0;
};

class HIDLOADER_API CHIDLoader {
public:

    CHIDLoader();

    ~CHIDLoader();

    LONG Open(WORD vid, WORD pid, HWND hParent, LPCTSTR filter = NULL);

    LONG Open(LPCTSTR path);

    LONG Close();

    BOOL LoadFile(LPCTSTR);

    BOOL ProgDevice(IProgressRender *pProgress);

    LONG WriteAndWait(void* pData, DWORD timeout = 2000);

    BOOL BeginReadData();

    LPCTSTR GetDevPath();

    virtual	void OnConnect(LPCTSTR path){}
    
    virtual	void OnDisconnect(LPCTSTR path){}

    virtual void OnReadData(BYTE* pData, size_t dataLen){}

    virtual void OnStartProg(){}

    virtual void OnStopProg(){}

    BOOL  GetIndexedString(ULONG index, PVOID buffer = NULL, ULONG len = 0);

    BOOL  GetSerialString(PVOID Buffer, ULONG BufferLength);

public:
    LRESULT	OnDeviceChange(WPARAM wParam, LPARAM lParam);
};
